package com.example.TEvaluation.contorller;

import com.example.TEvaluation.domain.User;
import com.example.TEvaluation.service.UserService;
import jdk.nashorn.internal.ir.RuntimeNode;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.http.HttpRequest;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping(value = "/user",method = {RequestMethod.POST,RequestMethod.GET})
   public String ToUser(User user, HttpServletRequest request){
         System.out.println("控制层");
        /*List<User> empList = userService.findall();
        *//*empList.add(new User(1,"留着","12","1"));
        empList.add(new User(1,"留着","12","1"));
        empList.add(new User(1,"留着","12","1"));
        empList.add(new User(1,"留着","12","1"));*//*
        for (User u :empList
             ) {
            System.out.print(u.getId()+u.getUsername());
        }
        map.put("we","我们");
        map.put("kn",empList);*/
//       String username="d";

        System.out.println("控制层");
        userService.login(user);
         HttpSession session=request.getSession(true);
            session.setAttribute("userinfo",user.getUserid());

       return   "/student/index";

        /*System.out.println(userService.findall(user.getUsername()));*/
      /* return  userService.findall(user.getUsername());*/
   }



}
